package com.zxw.third.controller;

import com.zxw.common.api.ApiResult;
import com.zxw.common.constant.ApiConst;
import com.zxw.common.entity.baidu.BaiduHotVO;
import com.zxw.common.enums.ResultCode;
import com.zxw.third.service.BaiduHotService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


/**
 * <p>
 * 百度热点接口
 * </p>
 *
 * @author zhanxuewei
 * @since 2022-10-11
 */
@Api(tags = "百度热点接口", description = "BaiduHotController")
@RestController
@RequestMapping(ApiConst.API_PREFIX + "/third/baidu/")
public class BaiduHotController {

    @Autowired
    private BaiduHotService baiduHotService;

    @ApiOperation("百度热搜")
    @GetMapping("/news/hot/list")
    public ApiResult<List<BaiduHotVO>> newsHotList() {
        List<BaiduHotVO> list = baiduHotService.newsHotList();
        return ApiResult.success(list);
    }

    @ApiOperation("入库百度热点新闻")
    @GetMapping("/news/save")
    public ApiResult<ResultCode> newsSave() {
        baiduHotService.newsSave();
        return ApiResult.success(ResultCode.SUCCESS);
    }

}

